Visual Studio Code For Development
Visual Studio Code is a source-code editor made by Microsoft with the Electron Framework (for Node.js web applications running on the Blink layout engine). Some of the prominent features include support for debugging, syntax highlighting, intelligent code completion, snippets, code refactoring, and embedded Git. It can be used for a variety of programming languages, including C, C#, C++, Fortran, Go, Java, PHP, JavaScript, Node.js, HTML, CSS, Python, Rust, Julia, and MATLAB. Additional extensions and functionality can be installed through the VS Code Marketplace. An alternative to Visual Studio Code is VSCodium, which is a community-driven and freely-licensed binary distribution of the open-source repository from which Visual Studio Code is also built. VSCodium avoids the proprietary licence which is applied to Visual Studio Code after it is built and any telemetry or tracking which may be sent to Microsoft, but an alternate central repository needs to be used for extensions, such as Open VSX which acts as an open-source registry for extensions.
Installation And Setup
...
On Debian, the easiest way to install Visual Studio Code is using the .DEB package. This will automatically install the Apt repository and signing key to enable auto-updating through the system package manager. Alternatively, the repository and signing key can be manually installed and integrated with the system package manager. Although not recommended, Visual Studio Code is also officially distributed as a Snap package from the Snap Store.
sudo apt-get install wget gpg wget -qO- https://packages.microsoft.com/keys/microsoft.asc | gpg --dearmor > packages.microsoft.gpg sudo install -D -o root -g root -m 644 packages.microsoft.gpg /etc/apt/keyrings/packages.microsoft.gpg sudo sh -c 'echo "deb [arch=amd64,arm64,armhf signed-by=/etc/apt/keyrings/packages.microsoft.gpg] https://packages.microsoft.com/repos/code stable main" > /etc/apt/sources.list.d/vscode.list' rm -f packages.microsoft.gpg sudo apt install apt-transport-https sudo apt install code
...In the environment... , a workspace is essentially a structured container for projects, settings, and configurations. It allows for the grouping of related files and folders and makes it more efficient to manage and switch between multiple projects simultaneously. This is often useful in defining tasks and debugging configurations specific to each project relative to the build systems, deployment processes, and other unique requirements. In addition, there is ... for integration with source control to allow for version control features in each project. Any functionality can also be ...enhanced... through extensions, which ... . When working in a team, it is possible to share the setup of a workspace to allow for consistent development environments across members (alternatively, this also implies that a workspace can be portable and easily moved between machines). The workspace setup is stored in ./project/.vscode/.code-workspace
.
There are advanced capacity for customization through the vast collection of settings. The settings are segmented into relevant categories for the theme, editor, workbench, terminal, files, folders, debugging, keybindings, accessibility, and extensions in relation to the editor, side bar, activity bar, panel, and status bar. These settings can also be separated for user settings, which apply globally to any instance, and workspace settings, which only apply to the current workspace and take precedence over the user settings. The settings setup is stored in ~/.config/Code/User/settings.json
or ./project/.vscode/settings.json
for the workspace.
{ "editor.minimap.enabled": false, "editor.roundedSelection": false, "workbench.colorTheme": "Default Light Modern", "workbench.startupEditor": "none", "workbench.sideBar.location": "right", "workbench.editor.showTabs": false, "workbench.editor.tabSizing": "fixed", "workbench.editor.tabSizingFixedMaxWidth": 200, "workbench.editor.tabSizingFixedMinWidth": 200, "[html]": { "editor.wordWrap": "wordWrapColumn", "editor.wordWrapColumn": 114, }, }
For reference, there is support for variable substitution relative to internal configuration. The most common variables include ${userHome}
for the absolute path to the home directory, ${workspaceFolder}
for the absolute path to the currently open workspace folder, ${file}
for the absolute path to the currently open file, ${relativeFile}
for the relative path to the currently open file from the workspace folder, ${fileBasename}
for the name of the currently open file, ${fileDirname}
for the absolute path to the folder of the currently open file, ${fileDirnameBasename}
for the name of the folder of the currently open file, ${lineNumber}
for the currently selected line number, and ${selectedText}
for the currently selected text. This notation can also be used to reference environment variables as ${env:name}
, internal settings as ${config:name}
, internal commands as ${command:name}
, or inputs to commands as ${input:name}
. These variables are usually most relevant to debugging and tasks.
Integrated Terminal ...
...
Custom Keyboard Shortcuts
...
Custom Snippets ...
...
Python ...
There are various extensions which are helpful in ...extending... functionality relative to programming in Python and with ..., such as IPython and Jupyter Notebooks. ...
- Python: ... Other key features include debugging, navigation, formatting, refactoring, variable explorer, and test explorer. Pylance will also be installed, which acts as a performant and feature-rich language server for intellisense and linting with Python.
- Jupyter: Provides basic notebook support for language kernels which are supported in Jupyter Notebooks and allows any Python environment to be used as a kernel (note that the
jupyter
package must already be installed in the Python environment). Jupyter Cell Tags, Jupyter Keymap, Jupyter Notebook Renderers, and Jupyter Slide Show will also be installed, which add further features and compatibility with Jupyter Notebooks.
...
"python.linting.enabled": true, "python.linting.pylintEnabled": true, "python.formatting.provider": "black", "python.analysis.typeCheckingMode": "basic",Briefly, a virtual environment is a self-contained directory containing an installation for a particular version of Python and additional packages and modules. Relative to the virtual environment, the path to the interpreter for IPython can be edited in preferences to point to the particular version of Python for the virtual environment (although this will need to be edited each time the virtual environment is changed). This can be associated with the current workspace folder.
~ $ python3 -m venv path/to/Environment
~ $ source path/to/Environment/bin/activate (Environment) ~ $ python3 -c "import sys; print(sys.executable)" (Environment) ~ $ deactivate Command Palette > Python: Select Interpreter
With regard to debugging, the settings for a debugging session are specified in launch.json
(stored at ./project/.vscode/launch.json
). This file contains configurations for different types of debugging scenarios and defines the request mode, name, interpreter (usually related to the virtual environment), program to debug, working directory, scope, console (in the internal console, integrated terminal, or external terminal) and arguments or environment variables to pass with the command. To mention, the ...types... of request modes include launch and attach, where launch will start the process in debug mode and ...contains... relevant instructions on how to start the process (typically used for local development), while attach expects the process to already be running in debug mode and ...contains... relevant instructions on how to connect to the process (typically used for production or remote development).
launch.json
used for a project integrating with Google Cloud Platform: { "version": "0.2.0", "configurations": [ { "name": "Python: Current File", "type": "python", "request": "launch", "program": "${file}", "args": [ "...", "...", "..." ], "env": [ "...", "...", "..." ], "console": "integratedTerminal", "justMyCode": true }, { "name": "Python: Current File", "type": "python", "request": "launch", "program": "${file}", "console": "integratedTerminal", "justMyCode": true } ] } PostgreSQL Databases
...
Git Source Control
...